﻿<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="MandoGroup.TFSEstimator._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h1>
        Home
    </h1>
    <div>
        <asp:Panel runat="server" ID="chooseTFSProjectPanel">
            <h2>
                Step 1</h2>
            <asp:Label runat="server" AssociatedControlID="tfsProjectSelector">Choose the TFS project</asp:Label>
            <asp:DropDownList runat="server" ID="tfsProjectSelector" />
            <br />
            <asp:Label ID="Label3" runat="server">WARNING: The TFS integration is a slow process, if you have a large project this will take some time so do not click the button below more than once.</asp:Label>
            <br />
            <asp:Button runat="server" Text="Choose Project" ID="chooseProjectButton" OnClick="chooseProjectButton_OnClick" />
        </asp:Panel>
        <asp:Panel runat="server" ID="allCurrentTasksPanel" Visible="false">
            <h2>
                Step 2</h2>
            <p>
                The table below shows all the current tasks available for the selected project.
                Make sure each row in the spreadsheet has the correct Task Id associated with it
            </p>
            <asp:DataGrid runat="server" ID="allCurrentTasks" AutoGenerateColumns="false">
                <Columns>
                    <asp:BoundColumn DataField="Id" HeaderText="Task Id" ReadOnly="false" />
                    <asp:BoundColumn DataField="Title" HeaderText="Title" ReadOnly="false" />
                    <asp:BoundColumn DataField="ItemEstimate" HeaderText="Item Estimate" ReadOnly="false" />
                    <asp:BoundColumn DataField="DisplayableChildWorkItemIds" HeaderText="Direct Children Ids"
                        ReadOnly="false" />
                    <asp:BoundColumn DataField="ChildrenEstimate" HeaderText="Children Estimate" ReadOnly="false" />
                    <asp:BoundColumn DataField="TotalEstimate" HeaderText="Total Estimate" ReadOnly="false" />
                </Columns>
            </asp:DataGrid>
            <h3>
                Choose file</h3>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="List"
                CssClass="error" ValidationGroup="UploadFileValidationGroup" />
            <asp:RegularExpressionValidator ID="FileUpLoadValidator" Display="None" runat="server"
                ErrorMessage="Upload Excel files only." ValidationExpression="^.+(.xlsx|.XLSX|.xls|XLS)$"
                ControlToValidate="fileUpload" ValidationGroup="UploadFileValidationGroup" />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="fileUpload"
                ErrorMessage="You must select a file to upload" Display="None" ValidationGroup="UploadFileValidationGroup" />
            <asp:CustomValidator runat="server" Display="None" ID="directoryCreateFailed" ErrorMessage="Error creating the directory to save your excel file"
                ValidationGroup="UploadFileValidationGroup" />
            <asp:CustomValidator runat="server" Display="None" ID="fileSaveFailed" ErrorMessage="Error saving your excel file"
                ValidationGroup="UploadFileValidationGroup" />
            <asp:CustomValidator runat="server" Display="None" ID="fileOpenFailed" ErrorMessage="Error opening your excel file"
                ValidationGroup="UploadFileValidationGroup" />
            <asp:PlaceHolder runat="server" ID="uploadButtonPlaceholder">
                <asp:Label ID="Label2" runat="server" Text="Choose File:" AssociatedControlID="fileUpload"
                    ValidationGroup="UploadFileValidationGroup" />
                <asp:FileUpload runat="server" ID="fileUpload" />
                <br />
                <asp:Button runat="server" Text="Upload" ID="uploadSpreadsheetButton" OnClick="uploadSpreadsheetButton_OnClick"
                    ValidationGroup="UploadFileValidationGroup" />
            </asp:PlaceHolder>
            <asp:PlaceHolder runat="server" ID="fileUploadedPlaceholder">
                <asp:Label runat="server">You uploaded file: </asp:Label>
                <strong>
                <asp:Literal runat="server" ID="fileName" EnableViewState="true"></asp:Literal>
                </strong>
            </asp:PlaceHolder>
        </asp:Panel>
        <asp:Panel runat="server" ID="setSpreadsheetSettingsPanel" Visible="false">
            <h2>
                Step 3</h2>
            <asp:Label runat="server" Text="Which work sheet should be used?" AssociatedControlID="sheetNamesDropdown" />
            <asp:DropDownList runat="server" ID="sheetNamesDropdown" />
            <br />
            <asp:Button runat="server" ID="chooseSpreadsheetNameButton" Text="Choose Columns"
                OnClick="chooseSpreadsheetNameDropdown_OnClick" />
        </asp:Panel>
        <asp:Panel runat="server" ID="processSpreadsheetPanel" Visible="false">
            <h2>
                Step 4</h2>
            <asp:Label runat="server" AssociatedControlID="chooseTFSIdColumn">Choose TFS Id column:</asp:Label>
            <asp:DropDownList runat="server" ID="chooseTFSIdColumn" />
            <br />
            <asp:Label ID="Label1" runat="server" AssociatedControlID="chooseSumEffortColumn">Choose effort sum column:</asp:Label>
            <asp:DropDownList runat="server" ID="chooseSumEffortColumn" />
            <br />
            <asp:Button runat="server" ID="processSpreadsheetButton" Text="Process Spreadsheet"
                OnClick="processSpreadsheet_OnClick" />
            <asp:Panel runat="server" ID="failedRowsPanel" Visible="false">
                <h3>
                    Errors found</h3>
                <p>
                    You have the below errors in your spreadsheet, do you want to continue with the
                    process?</p>
                <asp:Button runat="server" ID="confirmProcessButton" Text="Yes" OnClick="confirmProcessButton_OnClick" />
                <asp:Panel runat="server" ID="duplicateIdsPanel" Visible="false">
                    <h3>
                        Duplicate Ids</h3>
                    <asp:DataGrid runat="server" ID="duplicateIdsDatagrid" AutoGenerateColumns="true">
                    </asp:DataGrid>
                </asp:Panel>
                <asp:Panel runat="server" ID="nonIntIdsPanel" Visible="false">
                    <h3>
                        Non Integer Ids</h3>
                    <asp:DataGrid runat="server" ID="nonIntIdsDatagrid" AutoGenerateColumns="true">
                    </asp:DataGrid>
                </asp:Panel>
            </asp:Panel>
        </asp:Panel>
    </div>
</asp:Content>
